<?php require_once('../../Connections/cotiza.php'); ?>
<?php
$campo = $_GET['campo'];
$acc   = $_GET['acc'];
mysql_select_db($database_cotiza, $cotiza);

if($acc == "search")
{
	$b = $_POST['busqueda'];
	$query = "SELECT * FROM sus_mstr WHERE sus_id like '%$b%' or sus_tipo like '%$b%' or sus_desc like '%$b%' ORDER BY sus_id";
}
else
	$query = "SELECT * FROM sus_mstr ORDER BY sus_id";
	
$busqueda = mysql_query($query, $cotiza) or die(mysql_error());
$row = mysql_fetch_assoc($busqueda);
$totalRows = mysql_num_rows($busqueda);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>..:: Sustratos ::..</title>
<link href="../../main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.default_title {
	color: #FFF;
}
-->
</style>
</head>

<body onload="document.form1.busqueda.focus();">
<form id="form1" name="form1" method="post" action="sustratos.php?campo=<?php echo $campo; ?>&acc=search">
  <table border="0" align="center">
    <tr>
      <td >B&uacute;squeda de Sustrato:</td>
      <td ><input name="busqueda" class="default" size="20" autocomplete="off" /></td>
      <td ><input type="submit" value="Buscar" class="v8" /></td>
    </tr>
  </table>
</form>
<br />
<?php if($totalRows >0){?>
  <table width="356" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr class="default_title">
      <td width="63" align="center" bgcolor="#0000CC">Id Sustrato</td>
      <td width="110" align="center" bgcolor="#0000CC">Descripci&oacute;n</td>
      <td width="163" align="center" bgcolor="#0000CC">Grupo</td>
    </tr>
    <?php do { ?>
    <tr>
      <td width="63"><a href="javascript:window.opener.document.getElementById('<?php echo $campo; ?>').value= '<?php echo $row['sus_id']; ?>';window.opener.document.getElementById('<?php echo $campo; ?>').focus();window.close();"> <?php echo $row['sus_id']; ?> </a>&nbsp;</td>
      <td width="110"> <?php echo $row['sus_desc']; ?>&nbsp;</td>
      <td width="163"><?php echo $row['sus_grupo']; ?>&nbsp;</td>
    </tr>
      <?php } while ($row = mysql_fetch_assoc($busqueda)); ?>
  </table>
<?php }?>
</body>
</html>
<?php 
mysql_close($cotiza);
?>